<template>
    <div class="cartCommit">
        <van-nav-bar left-text="返回" left-arrow @click-left="$router.back()" />

        <van-row gutter="20">
            <van-col span="16" offset="4">
                <van-icon name="location-o" /> 收货人:{{nickname}} {{phone}}
            </van-col>
            <van-col span="16" offset="5">地址:{{address}} </van-col>
        </van-row>

        <van-divider :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }">
        </van-divider>

        <div class="cartList">
            <h4>购物清单</h4>
            <div v-if="!rushStore.check">
                <div v-for="item in store.cart">
                    <van-card v-if="item.check" :price="item.price" :title="item.title" :thumb="item.image"
                        :num="item.count" />
                </div>
            </div>
            <van-card v-if="rushStore.check" :price="rushItem.price" :title="rushItem.title" :thumb="rushItem.image"
                :num="1" />
        </div>

        <van-cell-group inset class="detail">
            <van-cell title="商品金额" v-if="!rushStore.check" :value="store.totalMoney" />
            <van-cell title="商品金额" v-else :value="rushItem.price" />
            <van-cell title="优惠券" value="暂无可用优惠券" />
            <van-cell title="红包" value="暂无红包" />
            <van-cell title="包装费" value="￥0" />
            <van-cell title="运费" value="￥0" />
        </van-cell-group>

        <van-cell-group inset class="ticket">
            <van-cell title="发票" is-link value="不开具发票" />
        </van-cell-group>
        <van-row class="commit">
            <van-col span="14" v-if="!rushStore.check">总计￥{{ store.totalMoney }}</van-col>
            <van-col span="14" v-else>总计￥{{ rushItem.price }}</van-col>
            <van-col span="10" style="background-color: green;color:white" @click="$router.push('/desk')">提交订单
            </van-col>
        </van-row>
    </div>


</template>

<script setup>
import useCartStore from '../../store/cart';
import useMenuStore from '../../store/menu';
import useUserStore from '../../store/user';
const store = useCartStore()
const rushStore = useMenuStore()
const userStore=useUserStore()
// console.log(userStore.address[0].addressDetail)
console.log(userStore.address)
const {address}=userStore.address[0]
// console.log(addressDetail)
const {nickname,phone}=userStore.userInfo
const rushItem = rushStore.commitList[0]
// const {address}=userStore.address[0]
// const {name,tel}=userStore.address[0]

</script>

<style lang="less" scoped>
.van-col {
    padding: 10px 0;
}

h4 {
    padding-left: 40px;
}

.detail {
    background-color: rgb(244, 244, 244);
    border-radius: 10px;
    margin: 0 10px;

    :deep(.van-cell__value span) {
        color: red;
    }
}

.ticket {
    background-color: rgb(244, 244, 244);
    border-radius: 10px;
    margin: 20px 10px;
}

.commit {
    text-align: center;
}
</style>
